package br.com.j7.jdesk.persistence.repository.impl;

import java.util.List;

import br.com.j7.jdesk.library.exception.RepositoryException;
import br.com.j7.jdesk.persistence.entity.Services;
import br.com.j7.jdesk.persistence.entity.ServicesLogs;
import br.com.j7.jdesk.persistence.repository.ServiceLogRepository;

/**
 * 
 * 
 * 
 * @author Edivando Alves
 *
 */
public class ServiceLogsRepositoryImpl extends AbstractRepository<ServicesLogs> implements ServiceLogRepository {

	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.impl.AbstractRepository#find(java.lang.Integer)
	 */
	@Override
	public ServicesLogs find(Integer id) throws RepositoryException {
		try {
			return getEntity(ServicesLogs.class, id);
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}

	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.impl.AbstractRepository#list()
	 */
	@Override
	public List<ServicesLogs> list() throws RepositoryException {
		try {
			return listByNamedQuery(ServicesLogs.class, "serviceLog");
		} catch (RepositoryException e) {
			throw new RepositoryException(e);
		}
	}
	
	/*
	 * (non-Javadoc)
	 * @see br.com.j7.jdesk.persistence.repository.ServiceLogRepository#listServicesLogByService(br.com.j7.jdesk.persistence.entity.Services)
	 */
	@Override
	public List<ServicesLogs> listServicesLogByService(Services service) {
		try {
			return listByNamedQuery(ServicesLogs.class, "serviceLogByService", service);
		} catch (RepositoryException e) {
			throw new RuntimeException(e); 
		}
	}
}
